package com.hd123.rumba.gwt.widget.client.grid;

import com.google.gwt.user.client.ui.HasAlignment;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;

public class StringRendererFactory extends CellRendererFactory implements HasHorizontalAlignment {
  public CellRenderer render(DxGrid grid, int row, int col, String text, String width,
      boolean readOnly, boolean selected) {
    StringRenderer widget = new StringRenderer();
    widget.setValue(text);
    grid.setWidget(row, col, widget);
    widget.setStyleName(selected ? selectedStyleName : styleName);
    widget.setWidth("100%");
    widget.setHeight("100%");
    grid.getCellFormatter().setHorizontalAlignment(row, col, align);
    return widget;
  }

  private HorizontalAlignmentConstant align = HasAlignment.ALIGN_LEFT;

  public HorizontalAlignmentConstant getHorizontalAlignment() {
    return align;
  }

  public void setHorizontalAlignment(HorizontalAlignmentConstant align) {
    this.align = align;
  }
}
